package com.lb.ui;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.google.gson.Gson;
import com.lb.R;
import com.lb.okhttp.callback.StringCallback;
import com.lb.utils.HttpClientUtil;

import java.io.IOException;
import java.util.HashMap;

import okhttp3.Call;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class MainActivity extends AppCompatActivity {
    public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        HashMap<String, String> parm = new HashMap<>();
        parm.put("categories", "jokes");
        parm.put("action", "next");
        parm.put("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFuZHJvaWQ6bGV3YV8xMjQiLCJhY2NvdW50X3R5cGUiOjIsInVzZXJfaWQiOiI1NzNiZDY2Y2NkZmZiYzc3NDY1NjZiYjAiLCJleHAiOjE0NzEzMTU1MzR9.6ZTYeceNLsuQt_suGV9tH_pfbGLptE0pggL0pM3H2Ic");
        parm.put("read_tag", "");
        Gson gson = new Gson();
        HttpClientUtil.useOkHttpPost(gson.toJson(parm), new StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                e.printStackTrace();
            }

            @Override
            public void onResponse(String response, int id) {
                Log.d("shunye", "response = " + response.toString());
            }
        });
    }
}
